<?php
class Myblog_Form_Visibility extends Zend_Form
{
public $formDecorators=array(
array('FormElements'),
array('Form'),
);
public $elementDecorators=array(
array('ViewHelper'),
array('Label'),
array('Errors'),
array('HtmlTag',array('dd'=>'span','dt'=>'span')),
);
public $buttonDecorators=array(
array('ViewHelper'),
array('HtmlTag',array('dd'=>'div','dt'=>'div','id'=>'button'))
);
	public function init()
	{
	$this->setAction('')
		->setMethod('post')
		->setName('options');
		//->setDecorators($this->formDecorators);

	$select=new Zend_Form_Element_Select('visibility');
	$select->setLabel('Опубликован:')
		->setOptions(array('size'=>1))
		->setRequired(true)
		->addValidator('Alnum')
		->addFilter('HtmlEntities')
		->addFilter('StripTags')
		->addFilter('StringTrim');
		//->setDecorators($this->elementDecorators);
		foreach($this->getVisibility() as $v)
		{
		$select->addMultiOption($v['visibility'],$v['title']);	
		}

	$id=new Zend_Form_Element_Hidden('id');
	$id->setOptions(array('size'=>1))
		->setRequired(true)
		->addFilter('HtmlEntities')
		->addValidator('NotEmpty')
		->addFilter('StripTags')
		->addValidator('Int')
		//->removeDecorator('Label','dt')
		//->removeDecorator('HtmlTag','dd')
		->addFilter('StringTrim');

	$submit=new Zend_Form_Element_Submit('submit');
	$submit->setLabel('ok');
		//->setDecorators($this->buttonDecorators);
		$this->addElements(array($select,$id,$submit));
	}
public function getVisibility()
	{
	$q=Doctrine_Query::create()
		->from('Myblog_Model_Visibility v');
	$result=$q->fetchArray();
	return $result;
	}
}
